package com.stxx.framwork.domain.model;

import cn.hutool.http.HttpStatus;
import com.stxx.framwork.domain.R;
import lombok.Data;

import java.util.List;

/**
 * @author Fuzhenlei
 * @date 2025/02/06 17:51
 */
@Data
public class PageResult<T> extends R<List<T>> {
    private static final long serialVersionUID = 1L;
    /**
     * 总记录数
     */
    private Long total;

    public PageResult() {

    }

    /**
     * 分页
     *
     * @param list  列表数据
     * @param total 总记录数
     */
    public PageResult(List<T> list, long total) {
        this.setData(list);
        this.total = total;
    }


    public static <T> PageResult<T> build(List<T> list, long total) {
        PageResult<T> rspData = new PageResult<>(list,total);
        rspData.setCode(HttpStatus.HTTP_OK);
        rspData.setMsg("查询成功");
        return rspData;
    }
}
